package com.example.demo.stream;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;

import java.io.InputStream;
import java.net.URL;
import java.util.*;

/**
 * 测试url加密
 *
 * @author ldl
 */
public class UrlMd5Demo {

    private final static Set<String> sets;

    static {
        sets = new HashSet<>();
        sets.add("http://img1.qianyuwang.com/img/ueditor/upload/image/41634/d219cf547449471cc7d6812ab5cb9663.jpg");
        sets.add("http://img1.qianyuwang.com/img/ueditor/upload/image/41634/85d31ecef0a52ea62bc5964c616ba9c.jpg");
        sets.add("http://img1.qianyuwang.com/img/ueditor/upload/image/41634/04a7ec39a3756974be474969c3b6e7b.jpg");
    }

    public static void main(String[] args) {
        try {

            List<Integer> ints = Arrays.asList(1, 2, 2, 3, 4, 5, 5);
            System.out.println(ints.stream().anyMatch(x->x.equals(1)));
            System.out.println(ints.stream().anyMatch(x->x.equals(2)));



            StopWatch stopWatch = StopWatch.createStarted();
            String imgUrl = "https://t9.baidu.com/it/u=2403373727,1073565799&fm=199&app=68&f=PNG?w=700&h=605&s=3020DA15C6C70EE81C38E4CC03006093";
            URL url = new URL(imgUrl);
            InputStream inputStream = url.openStream();
            //byte[] bytes = IOUtils.toByteArray(inputStream);
            System.out.println(DigestUtils.md5Hex(inputStream));
            System.out.println(stopWatch.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
